
// Get the path of the currently running do-file
local do_file_path `c(pwd)'

// Change the working directory to the location of the do-file
cd "`do_file_path'"

clear
use "proc_data\AIRPORT2020-09-21.dta"
rename *, lower

g tto2airctr = .
replace tto2airctr = tto2aircmr if gid_0=="CMR"
replace tto2airctr = tto2airner if gid_0=="NER"
replace tto2airctr = tto2airnga if gid_0=="NGA"
replace tto2airctr = tto2airtcd if gid_0=="TCD"

rename tto2air tto2airlcd 
label variable tto2airlcd "Travel time to any airport in the 4 lake chad countries"
label variable tto2airctr "Travel time to any airport within the country"

drop tto2aircmr tto2airner tto2airnga tto2airtcd

save "proc_data\AIRPORT.dta", replace

clear
use "proc_data\AIRPORTDIST2020-09-21.dta"
rename *, lower
rename dist2airport_afr dist2airafr
rename dist2airall dist2airlcd

g dist2airctr = .
replace dist2airctr = dist2airport_cmr if gid_0=="CMR"
replace dist2airctr = dist2airport_ner if gid_0=="NER"
replace dist2airctr = dist2airport_nga if gid_0=="NGA"
replace dist2airctr = dist2airport_tcd if gid_0=="TCD"

drop dist2airport_cmr-dist2airport_tcd

label variable dist2airafr "Distance from grid pt to any airport in Africa"
label variable dist2airlcd "Distance from grid pt to any airport in the 4 lake chad countries"
label variable dist2airctr "Distance from grid pt to any airport within the country"

sort objectid gid_0
merge 1:1 objectid gid_0 using "proc_data\AIRPORT.dta"
drop _merge

save "proc_data\AIRPORT.dta", replace